package top.eggcode.common.thread;

import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import top.eggcode.common.model.Run;

import java.util.function.Consumer;

/**
 * Title: 异步执行器
 * Description: TODO
 * Date: 2021/5/28 23:46
 *
 * @author JiaQi Ding
 * @version 1.0
 */
@Component
public class AsyncExecutor {

    @Async
    public <T> void commit(Consumer<T> action, T param) {
        action.accept(param);
    }

    @Async
    public <T> void commit(Run action) {
        action.start();
    }
}
